<?php
// +----------------------------------------------------------------------
// | Author: yaoyihong <510974211@qq.com>
// +----------------------------------------------------------------------
namespace addon\slide\logic;
use app\common\logic\LogicBase;
use \tpfcore\Core;
/**
 *  幻灯片逻辑
 */
class SlideCat extends LogicBase
{
	public function saveSlideCat($data){
        $validate=Core::addonValidate($this->name);
        $validate_result = $validate->scene('add')->check($data);
        if (!$validate_result) {
            return [RESULT_ERROR, $validate->getError(), null];
        }

		$last_id=Core::loadAddonModel($this->name)->saveObject($data);
		if($last_id){
        	return [RESULT_SUCCESS, '操作成功', Core::addons_url("Slide://SlideCat/index")];
        }else{
        	return [RESULT_ERROR, '操作失败', Core::addons_url("Slide://SlideCat/index")];
        }
	}
	public function delSlideCat($data){
		return Core::loadAddonModel($this->name)->deleteObject($data,true)?[RESULT_SUCCESS, '删除成功', Core::addons_url("Slide://SlideCat/index")]:[RESULT_ERROR, '删除失败', Core::addons_url("Slide://SlideCat/index")];
	}
	public function getSlideCat($data=[]){
		return self::getList($data);
	}
}